﻿<%@ WebHandler Language="C#" Class="ExecuteFile" %>

using System;
using System.Web;
using System.IO;
using System.Collections;

public class ExecuteFile : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        //context.Response.Write("Hello World");
        string pathstring = context.Request.Params["Imgurl"].ToString();
        string[] pathArray = pathstring.Split('|');
        string mainpath = HttpContext.Current.Server.MapPath("/");
        foreach (var path in pathArray)               //使用foreach 遍历
        {
            if (File.Exists( mainpath + path))
            {
                FileInfo fi = new FileInfo( mainpath + path);
                if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                    fi.Attributes = FileAttributes.Normal;
                File.Delete( mainpath + path);
            }
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}